## This file makes the chord diagram for the democracy example

# plot ----------------------
load("lipset/out/lipset_out_pois.rda")

# Aggregation
# see documentation for BRS::agg_BRS
set.seed(123)
agg <- agg_BRS(fit=out_lipset_boot, X=X, Y=Y, maxLen=3, split = F, minProp = .05,
               simplify = T, oppmat=oppmat, oppind=oppind)

# chord diagram
png("figures/lipset_chord.png", width = 2, height = 2.25, units = 'in', res = 300)

# see helper.R for documentation on plot_chord function
plot_chord(agg, featureGroups=fgs,
           linkColors=RColorBrewer::brewer.pal(9, "Set3")[c(6,5)], 
           gridColors = "grey", 
           textSize = 1, side_mar=0, top_mar=0)
dev.off()
